<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>项目总结 | Bob周的空间</title><meta name="author" content="周天赐"><meta name="copyright" content="周天赐"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="项目总结516红包雨项目总结缓存预热： 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566&#x2F;** * 定时执行缓存预热任务 * 该方法使用CRON表达式“0 * * * * ?”定时执行，每一分钟执行一次">
<meta property="og:type" content="article">
<meta property="og:title" content="项目总结">
<meta property="og:url" content="https://github.com/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%A1%B9%E7%9B%AE%E6%80%BB%E7%BB%93/index.html">
<meta property="og:site_name" content="Bob周的空间">
<meta property="og:description" content="项目总结516红包雨项目总结缓存预热： 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566&#x2F;** * 定时执行缓存预热任务 * 该方法使用CRON表达式“0 * * * * ?”定时执行，每一分钟执行一次">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://github.com/Bob20020619/Bob20020619.github.io/img/avatar.jpg">
<meta property="article:published_time" content="2024-06-16T06:23:46.852Z">
<meta property="article:modified_time" content="2024-06-16T06:29:53.124Z">
<meta property="article:author" content="周天赐">
<meta property="article:tag" content="Markdown">
<meta property="article:tag" content="干货">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://github.com/Bob20020619/Bob20020619.github.io/img/avatar.jpg"><link rel="shortcut icon" href="/Bob20020619/Bob20020619.github.io/img/favicon.png"><link rel="canonical" href="https://github.com/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%A1%B9%E7%9B%AE%E6%80%BB%E7%BB%93/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/Bob20020619/Bob20020619.github.io/css/index.css?v=4.13.0"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.33/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/Bob20020619/Bob20020619.github.io/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid@4.11.1/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '项目总结',
  isPost: true,
  isHome: false,
  isHighlightShrink: true,
  isToc: true,
  postUpdate: '2024-06-16 14:29:53'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><meta name="generator" content="Hexo 7.2.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/Bob20020619/Bob20020619.github.io/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/Bob20020619/Bob20020619.github.io/archives/"><div class="headline">文章</div><div class="length-num">8</div></a><a href="/Bob20020619/Bob20020619.github.io/tags/"><div class="headline">标签</div><div class="length-num">3</div></a><a href="/Bob20020619/Bob20020619.github.io/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg fixed" id="page-header"><nav id="nav"><span id="blog-info"><a href="/Bob20020619/Bob20020619.github.io/" title="Bob周的空间"><img class="site-icon" src="/Bob20020619/Bob20020619.github.io/img/avatar.jpg"/><span class="site-name">Bob周的空间</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">项目总结</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-06-16T06:23:46.852Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-06-16T06:29:53.124Z" title="更新于 2024-06-16 14:29:53">2024-06-16</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/Bob20020619/Bob20020619.github.io/categories/%E9%A1%B9%E7%9B%AE/">项目</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="项目总结"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="项目总结"><a href="#项目总结" class="headerlink" title="项目总结"></a>项目总结</h1><h1 id="516红包雨项目总结"><a href="#516红包雨项目总结" class="headerlink" title="516红包雨项目总结"></a>516红包雨项目总结</h1><p>缓存预热：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 定时执行缓存预热任务</span></span><br><span class="line"><span class="comment"> * 该方法使用CRON表达式“0 * * * * ?”定时执行，每一分钟执行一次。</span></span><br><span class="line"><span class="comment"> * 执行流程包括查询1分钟内的活动，并对每个活动进行缓存预热处理：</span></span><br><span class="line"><span class="comment"> * 1. 查询活动列表。</span></span><br><span class="line"><span class="comment"> * 2. 遍历活动列表，针对每个活动查询奖品列表及数量、缓存活动策略，并生成奖品相关的令牌桶。</span></span><br><span class="line"><span class="comment"> * 3. 将活动策略和活动信息缓存到Redis中，包括最大中奖数、最大抽奖数、活动信息和令牌桶。</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@Scheduled(cron = &quot;0 * * * * ?&quot;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">execute</span><span class="params">()</span> &#123;</span><br><span class="line">    System.out.printf(<span class="string">&quot;scheduled!&quot;</span>+<span class="keyword">new</span> <span class="title class_">Date</span>());</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 缓存预热流程**：</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 1、查询1分钟内的活动</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 2、循环遍历活动列表，挨个处理，假设当前取出的是A</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 3、查询A相关的奖品列表及数量</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 4、根据总数量生成奖品相关的令牌桶，详细设计参考**《缓存预热设计》视频**</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 5、查询A相关的活动策略：抽奖次数、中奖次数等，放入Redis</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 查询1分钟内的活动</span></span><br><span class="line">    List&lt;CardGame&gt; games = gameService.list(<span class="keyword">new</span> <span class="title class_">QueryWrapper</span>&lt;CardGame&gt;().lambda().between(CardGame::getStarttime, <span class="keyword">new</span> <span class="title class_">Date</span>(), DateUtils.addMinutes(<span class="keyword">new</span> <span class="title class_">Date</span>(), <span class="number">1</span>)));</span><br><span class="line">    <span class="comment">// 循环遍历活动列表，进行缓存预热处理</span></span><br><span class="line">    <span class="keyword">for</span> (CardGame game : games) &#123;</span><br><span class="line">        <span class="comment">// 查询活动相关的奖品列表及数量</span></span><br><span class="line">        List&lt;CardProductDto&gt; products = gameLoadService.getByGameId(game.getId());</span><br><span class="line">        <span class="comment">// 缓存活动策略：最大中奖数和最大抽奖数</span></span><br><span class="line">        List&lt;CardGameRules&gt; list = gameRulesService.list(Wrappers.&lt;CardGameRules&gt;lambdaQuery().eq(CardGameRules::getGameid, game.getId()));</span><br><span class="line">        Map&lt;String,Object&gt; maxGoalMap = <span class="keyword">new</span> <span class="title class_">HashMap</span>&lt;&gt;();</span><br><span class="line">        Map&lt;String,Object&gt; maxEnterMap = <span class="keyword">new</span> <span class="title class_">HashMap</span>&lt;&gt;();</span><br><span class="line">        <span class="keyword">for</span> (CardGameRules r : list) &#123;</span><br><span class="line">            maxGoalMap.put(r.getUserlevel().toString(),r.getGoalTimes());</span><br><span class="line">            maxEnterMap.put(r.getUserlevel().toString(),r.getEnterTimes());</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 将最大中奖数和最大抽奖数缓存到Redis</span></span><br><span class="line">        redisUtil.hmset(RedisKeys.MAXGOAL + game.getId(),maxGoalMap );</span><br><span class="line">        redisUtil.hmset(RedisKeys.MAXENTER + game.getId(),maxEnterMap);</span><br><span class="line">        <span class="comment">// 缓存活动基本信息到Redis</span></span><br><span class="line">        redisUtil.set(RedisKeys.INFO+game.getId(),game,-<span class="number">1</span>);</span><br><span class="line">        <span class="comment">// 根据奖品列表生成令牌桶，并缓存到Redis</span></span><br><span class="line">        <span class="type">long</span> <span class="variable">start</span> <span class="operator">=</span> game.getStarttime().getTime();</span><br><span class="line">        <span class="type">long</span> <span class="variable">end</span> <span class="operator">=</span> game.getEndtime().getTime();</span><br><span class="line">        List&lt;Long&gt; tokenList = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;&gt;();</span><br><span class="line">        <span class="keyword">for</span>(CardProductDto product : products)&#123;</span><br><span class="line">            <span class="comment">// 根据奖品总数量生成令牌</span></span><br><span class="line">            <span class="type">Integer</span> <span class="variable">productAmount</span> <span class="operator">=</span> product.getAmount();</span><br><span class="line">            <span class="keyword">for</span>(<span class="type">int</span> i=<span class="number">0</span>;i&lt;productAmount;i++)&#123;</span><br><span class="line">                <span class="comment">// 在活动时间范围内生成随机时间戳，避免重复</span></span><br><span class="line">                <span class="type">long</span> <span class="variable">duration</span> <span class="operator">=</span> end-start;</span><br><span class="line">                <span class="type">long</span> <span class="variable">rnd</span> <span class="operator">=</span> start + <span class="keyword">new</span> <span class="title class_">Random</span>().nextInt((<span class="type">int</span>)duration);</span><br><span class="line">                <span class="type">long</span> <span class="variable">token</span> <span class="operator">=</span> rnd * <span class="number">1000</span> + <span class="keyword">new</span> <span class="title class_">Random</span>().nextInt(<span class="number">999</span>);</span><br><span class="line">                redisUtil.set(RedisKeys.TOKEN + game.getId() +<span class="string">&quot;_&quot;</span>+token,product,(end - rnd)/<span class="number">1000</span>);</span><br><span class="line">                tokenList.add(token);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 对令牌进行排序，并存储到Redis</span></span><br><span class="line">        Collections.sort(tokenList);</span><br><span class="line">        redisUtil.lSet(RedisKeys.TOKENS + game.getId(),tokenList,(end-start)/<span class="number">1000</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<p>抽奖接口：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 用户参与抽奖的接口</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> gameid 活动id，用于指定具体的抽奖活动</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> request 用户的请求对象，用于获取用户信息</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@return</span> 返回抽奖结果，包括状态码、消息和奖品信息（如果中奖）</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@GetMapping(&quot;/go/&#123;gameid&#125;&quot;)</span></span><br><span class="line"><span class="meta">@ApiOperation(value = &quot;抽奖&quot;)</span></span><br><span class="line"><span class="meta">@ApiImplicitParams(&#123;</span></span><br><span class="line"><span class="meta">    @ApiImplicitParam(name=&quot;gameid&quot;,value = &quot;活动id&quot;,example = &quot;1&quot;,required = true)</span></span><br><span class="line"><span class="meta">&#125;)</span></span><br><span class="line"><span class="keyword">public</span> ApiResult&lt;Object&gt; <span class="title function_">act</span><span class="params">(<span class="meta">@PathVariable</span> <span class="type">int</span> gameid, HttpServletRequest request)</span>&#123;</span><br><span class="line">    <span class="comment">// 检查活动是否已开始</span></span><br><span class="line">    <span class="keyword">if</span>(redisUtil.get(RedisKeys.INFO+gameid)==<span class="literal">null</span>)&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">ApiResult</span>&lt;&gt;(-<span class="number">1</span>,<span class="string">&quot;活动未开始&quot;</span>,<span class="literal">null</span>);</span><br><span class="line">    &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">        <span class="type">CardGame</span> <span class="variable">game</span> <span class="operator">=</span> (CardGame) redisUtil.get(RedisKeys.INFO+gameid);</span><br><span class="line">        <span class="keyword">if</span>(game.getEndtime().getTime()&lt;<span class="keyword">new</span> <span class="title class_">Date</span>().getTime())&#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">ApiResult</span>&lt;&gt;(-<span class="number">1</span>,<span class="string">&quot;活动已结束&quot;</span>,<span class="literal">null</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 从session中获取用户信息</span></span><br><span class="line">    <span class="type">CardUser</span> <span class="variable">user</span> <span class="operator">=</span> (CardUser) request.getSession().getAttribute(<span class="string">&quot;user&quot;</span>);</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 检查用户是否有抽奖次数</span></span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">    if(redisUtil.get(RedisKeys.USERGAME+gameid+&quot;_&quot;+user.getId())!=null) &#123;</span></span><br><span class="line"><span class="comment">        String level = String.valueOf(user.getLevel());</span></span><br><span class="line"><span class="comment">        Map&lt;Object, Object&gt; maxEnterCountMap = redisUtil.hmget(RedisKeys.MAXENTER + gameid);</span></span><br><span class="line"><span class="comment">        Map&lt;Object, Object&gt; maxGoalCountMap = redisUtil.hmget(RedisKeys.MAXGOAL + gameid);</span></span><br><span class="line"><span class="comment">        int maxEnterCount = (int) maxEnterCountMap.get(level + &quot;&quot;);</span></span><br><span class="line"><span class="comment">        int maxGoalCount = (int) maxGoalCountMap.get(level + &quot;&quot;);</span></span><br><span class="line"><span class="comment">        int userEnterCount = (int) redisUtil.get(RedisKeys.USERENTER + gameid + &quot;_&quot; + user.getId());</span></span><br><span class="line"><span class="comment">        int userGoalCount = 0;</span></span><br><span class="line"><span class="comment">        if (redisUtil.get(RedisKeys.USERHIT + gameid + &quot;_&quot; + user.getId()) != null) &#123;</span></span><br><span class="line"><span class="comment">            userGoalCount = (int) redisUtil.get(RedisKeys.USERHIT + gameid + &quot;_&quot; + user.getId());</span></span><br><span class="line"><span class="comment">        &#125;</span></span><br><span class="line"><span class="comment">        if (userEnterCount == maxEnterCount) &#123;</span></span><br><span class="line"><span class="comment">            return new ApiResult&lt;&gt;(-1, &quot;抽奖次数已用完&quot;, null);</span></span><br><span class="line"><span class="comment">        &#125;</span></span><br><span class="line"><span class="comment">        if (userGoalCount == maxGoalCount) &#123;</span></span><br><span class="line"><span class="comment">            return new ApiResult&lt;&gt;(-1, &quot;您已达最大中奖数&quot;, null);</span></span><br><span class="line"><span class="comment">        &#125;</span></span><br><span class="line"><span class="comment">    &#125;</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 获取当前时间戳</span></span><br><span class="line">    <span class="type">long</span> <span class="variable">currentTimeMillis</span> <span class="operator">=</span> System.currentTimeMillis();</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 调用Lua脚本进行抽奖，返回奖品令牌或状态码</span></span><br><span class="line">    <span class="type">Long</span> <span class="variable">prizeToken</span> <span class="operator">=</span> luaScript.tokenCheck(RedisKeys.TOKENS+gameid, String.valueOf(currentTimeMillis));</span><br><span class="line">    <span class="keyword">if</span>(redisUtil.get(RedisKeys.USERGAME+gameid+<span class="string">&quot;_&quot;</span>+user.getId())==<span class="literal">null</span>)&#123;</span><br><span class="line">        redisUtil.set(RedisKeys.USERGAME+gameid+<span class="string">&quot;_&quot;</span>+user.getId(),user);</span><br><span class="line">    &#125;</span><br><span class="line">    redisUtil.incr(RedisKeys.USERENTER+gameid+<span class="string">&quot;_&quot;</span>+user.getId(),<span class="number">1</span>);</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 记录用户参与抽奖信息到 RabbitMQ 消息队列</span></span><br><span class="line">    <span class="type">CardUserGame</span> <span class="variable">cardUserGame</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">CardUserGame</span>();</span><br><span class="line">    cardUserGame.setUserid(user.getId());</span><br><span class="line">    cardUserGame.setGameid(gameid);</span><br><span class="line">    cardUserGame.setCreatetime(<span class="keyword">new</span> <span class="title class_">Date</span>());</span><br><span class="line">    rabbitTemplate.convertAndSend(RabbitKeys.EXCHANGE_DIRECT,RabbitKeys.QUEUE_PLAY,JSONObject.toJSONString(cardUserGame));</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 处理抽奖结果</span></span><br><span class="line">    <span class="keyword">if</span>(prizeToken == <span class="number">0L</span>)&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">ApiResult</span>&lt;&gt;(-<span class="number">1</span>,<span class="string">&quot;奖品已抽完&quot;</span>,<span class="literal">null</span>);</span><br><span class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span> (prizeToken == <span class="number">1</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">ApiResult</span>&lt;&gt;(<span class="number">0</span>,<span class="string">&quot;未中奖&quot;</span>,<span class="literal">null</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 更新用户中奖次数</span></span><br><span class="line">    redisUtil.incr(RedisKeys.USERHIT+gameid+<span class="string">&quot;_&quot;</span>+user.getId(),<span class="number">1</span>);</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 根据令牌获取奖品信息</span></span><br><span class="line">    <span class="type">CardProductDto</span> <span class="variable">prize</span> <span class="operator">=</span> (CardProductDto) redisUtil.get(RedisKeys.TOKEN + gameid + <span class="string">&quot;_&quot;</span> + prizeToken);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 记录用户中奖信息到 RabbitMQ 消息队列</span></span><br><span class="line">    <span class="type">CardUserHit</span> <span class="variable">cardUserHit</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">CardUserHit</span>();</span><br><span class="line">    cardUserHit.setGameid(gameid);</span><br><span class="line">    cardUserHit.setUserid(user.getId());</span><br><span class="line">    cardUserHit.setProductid(prize.getId());</span><br><span class="line">    cardUserHit.setHittime(<span class="keyword">new</span> <span class="title class_">Date</span>());</span><br><span class="line">    rabbitTemplate.convertAndSend(RabbitKeys.EXCHANGE_DIRECT,RabbitKeys.QUEUE_HIT,JSONObject.toJSONString(cardUserHit));</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 返回中奖结果给前端</span></span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">ApiResult</span>&lt;&gt;(<span class="number">1</span>,<span class="string">&quot;恭喜中奖&quot;</span>,prize);</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>





<p>使用Lua脚本来操作令牌桶：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * LuaScript 服务类，用于执行 Lua 脚本进行抽奖逻辑</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@Service</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">LuaScript</span> &#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 自动注入 Redis 模板，用于与 Redis 数据库交互</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> RedisTemplate redisTemplate;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 存储 Lua 脚本对象，用于执行 Lua 脚本</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="keyword">private</span> DefaultRedisScript&lt;Long&gt; script;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 初始化方法，在 Spring 容器初始化时自动调用</span></span><br><span class="line"><span class="comment">     * 设置 Lua 脚本的类型和来源</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@PostConstruct</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">init</span><span class="params">()</span> &#123;</span><br><span class="line">        script = <span class="keyword">new</span> <span class="title class_">DefaultRedisScript</span>&lt;&gt;();</span><br><span class="line">        script.setResultType(Long.class); <span class="comment">// 设置脚本返回值类型为 Long</span></span><br><span class="line">        script.setScriptSource(<span class="keyword">new</span> <span class="title class_">ResourceScriptSource</span>(<span class="keyword">new</span> <span class="title class_">ClassPathResource</span>(<span class="string">&quot;lua/tokenCheck.lua&quot;</span>))); <span class="comment">// 设置 Lua 脚本资源路径</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 执行 Lua 脚本检查抽奖状态</span></span><br><span class="line"><span class="comment">     * </span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> gamekey Redis 中存储奖品令牌的键，通常为 &quot;tokens&quot;+&quot;活动ID&quot;</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> curtime 当前时间戳，用于检查抽奖有效性</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span> 脚本执行结果，0 表示奖池已空，1 表示有令牌但未中奖，其他值表示已中奖的令牌</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="keyword">public</span> Long <span class="title function_">tokenCheck</span><span class="params">(String gamekey, String curtime)</span> &#123;</span><br><span class="line">        <span class="comment">// 准备 Lua 脚本执行所需键列表</span></span><br><span class="line">        List&lt;String&gt; keys = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;&gt;();</span><br><span class="line">        keys.add(gamekey);</span><br><span class="line">        keys.add(curtime);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 使用 RedisTemplate 执行 Lua 脚本</span></span><br><span class="line">        <span class="type">Long</span> <span class="variable">result</span> <span class="operator">=</span> (Long) redisTemplate.execute(script, keys, <span class="number">0</span>, <span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 返回脚本执行结果</span></span><br><span class="line">        <span class="keyword">return</span> result;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<figure class="highlight lua"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- Lua 脚本，用于抽奖逻辑检查</span></span><br><span class="line"><span class="comment">-- KEYS[1] 为存储奖品令牌的列表键，通常为 &quot;tokens&quot;+&quot;活动ID&quot;</span></span><br><span class="line"><span class="comment">-- KEYS[2] 为当前时间戳，用于检查抽奖有效性</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 从列表头部取出一个令牌（奖品）</span></span><br><span class="line"><span class="keyword">local</span> token = redis.call(<span class="string">&#x27;lpop&#x27;</span>, KEYS[<span class="number">1</span>])</span><br><span class="line"><span class="comment">-- 将取出的令牌转换为数值类型</span></span><br><span class="line"><span class="keyword">local</span> curtime = <span class="built_in">tonumber</span>(KEYS[<span class="number">2</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 检查令牌是否有效</span></span><br><span class="line"><span class="keyword">if</span> token ~= <span class="literal">false</span> <span class="keyword">then</span></span><br><span class="line">    <span class="comment">-- 如果令牌时间戳大于当前时间，说明已过期</span></span><br><span class="line">    <span class="keyword">if</span> (<span class="built_in">tonumber</span>(token) / <span class="number">1000</span> &gt; curtime) <span class="keyword">then</span></span><br><span class="line">        <span class="comment">-- 将过期的令牌放回列表头部</span></span><br><span class="line">        redis.call(<span class="string">&#x27;lpush&#x27;</span>, KEYS[<span class="number">1</span>], token)</span><br><span class="line">        <span class="comment">-- 返回 1，表示有令牌但未中奖</span></span><br><span class="line">        <span class="keyword">return</span> <span class="number">1</span></span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">        <span class="comment">-- 返回令牌值，表示中奖</span></span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">tonumber</span>(token)</span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">    <span class="comment">-- 如果列表为空，返回 0，表示奖池已空</span></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>这段 Lua 脚本用于抽奖逻辑检查。它从 Redis 的列表中弹出一个令牌，然后比较令牌的时间戳和当前时间。如果令牌已经过期（即时间戳大于当前时间），则将其放回列表头部并返回 1，表示有令牌但未中奖；否则，返回令牌值，表示中奖。如果列表为空，说明奖池已空，返回 0。</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://github.com/Bob20020619/Bob20020619.github.io">周天赐</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://github.com/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%A1%B9%E7%9B%AE%E6%80%BB%E7%BB%93/">https://github.com/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%A1%B9%E7%9B%AE%E6%80%BB%E7%BB%93/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://github.com/Bob20020619/Bob20020619.github.io" target="_blank">Bob周的空间</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/Markdown/">Markdown</a><a class="post-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/%E5%B9%B2%E8%B4%A7/">干货</a></div><div class="post_share"><div class="social-share" data-image="/Bob20020619/Bob20020619.github.io/img/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1.1.3/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1.1.3/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E8%B5%B0%E9%A9%AC%E8%A7%82%E8%8A%B1/" title="走马观花"><img class="cover" src="/Bob20020619/Bob20020619.github.io/img/top.JPG" onerror="onerror=null;src='/Bob20020619/Bob20020619.github.io/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">走马观花</div></div></a></div><div class="next-post pull-right"><a href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E6%A8%A1%E6%8B%9F%E9%9D%A2%E8%AF%95/" title="模拟面试"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">模拟面试</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E4%BB%8EGitLab%E4%B8%8A%E6%8B%89%E5%8F%96%E9%A1%B9%E7%9B%AE/" title="从GitLab上拉取项目"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-06-16</div><div class="title">从GitLab上拉取项目</div></div></a></div><div><a href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E5%A4%A7%E8%AF%9D%E9%9D%A2%E8%AF%95/" title="大话面试"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-06-16</div><div class="title">大话面试</div></div></a></div><div><a href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%9D%A2%E8%AF%95%E7%BB%8F%E5%8E%86%E8%AE%B0%E5%BD%95/" title="面试经历记录"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-06-16</div><div class="title">面试经历记录</div></div></a></div><div><a href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E8%B5%B0%E9%A9%AC%E8%A7%82%E8%8A%B1/" title="走马观花"><img class="cover" src="/Bob20020619/Bob20020619.github.io/img/top.JPG" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-06-16</div><div class="title">走马观花</div></div></a></div><div><a href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E6%A8%A1%E6%8B%9F%E9%9D%A2%E8%AF%95/" title="模拟面试"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-06-16</div><div class="title">模拟面试</div></div></a></div><div><a href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95/" title="代码随想录"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-06-16</div><div class="title">代码随想录</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/Bob20020619/Bob20020619.github.io/img/avatar.jpg" onerror="this.onerror=null;this.src='/Bob20020619/Bob20020619.github.io/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">周天赐</div><div class="author-info__description">糟糕，他好像真的在变强！</div></div><div class="card-info-data site-data is-center"><a href="/Bob20020619/Bob20020619.github.io/archives/"><div class="headline">文章</div><div class="length-num">8</div></a><a href="/Bob20020619/Bob20020619.github.io/tags/"><div class="headline">标签</div><div class="length-num">3</div></a><a href="/Bob20020619/Bob20020619.github.io/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div><a id="card-info-btn" href="https://github.com/Bob20020619"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Bob20020619" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:1294811773@qq.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">糟糕，他好像真的在变强！</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%A1%B9%E7%9B%AE%E6%80%BB%E7%BB%93"><span class="toc-number">1.</span> <span class="toc-text">项目总结</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#516%E7%BA%A2%E5%8C%85%E9%9B%A8%E9%A1%B9%E7%9B%AE%E6%80%BB%E7%BB%93"><span class="toc-number">2.</span> <span class="toc-text">516红包雨项目总结</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E8%B5%B0%E9%A9%AC%E8%A7%82%E8%8A%B1/" title="走马观花">走马观花</a><time datetime="2024-06-16T06:23:46.853Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%A1%B9%E7%9B%AE%E6%80%BB%E7%BB%93/" title="项目总结">项目总结</a><time datetime="2024-06-16T06:23:46.852Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E6%A8%A1%E6%8B%9F%E9%9D%A2%E8%AF%95/" title="模拟面试">模拟面试</a><time datetime="2024-06-16T06:23:46.851Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%9D%A2%E8%AF%95%E7%BB%8F%E5%8E%86%E8%AE%B0%E5%BD%95/" title="面试经历记录">面试经历记录</a><time datetime="2024-06-16T06:23:46.849Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E5%A4%A7%E8%AF%9D%E9%9D%A2%E8%AF%95/" title="大话面试">大话面试</a><time datetime="2024-06-16T06:23:46.843Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2024 By 周天赐</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Bob周的博客</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/Bob20020619/Bob20020619.github.io/js/utils.js?v=4.13.0"></script><script src="/Bob20020619/Bob20020619.github.io/js/main.js?v=4.13.0"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.33/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>